
#ifndef _MEMBER_BTEXTEDIT_H_
#define _MEMBER_BTEXTEDIT_H_

#include <BMap>
#include <BColor>
#include <BRect>
#include <BPoint>
#include <BString>
#include <BRange>
#include <BTextEdit>
#include <BPainter>
#include "ILineBlock.h"

namespace BWE
{
	class member_BTextEdit
	{
	public:
		member_BTextEdit(BTextEdit* textEdit);
		~member_BTextEdit();

		void initBlocks();
		void appendBlocks(const BString& str);
		void freshBlocks();
		void freshVisualRange();
		void freshInputLine();
		void wrapInputLine();

		bool seekPrevWord();
		bool seekNextWord();
		bool seekPrev();
		bool seekNext();
		bool seekUp();
		bool seekDown();

		bool input(const BCode& code);
		bool input(const BString& text);

		bool selectBlocks();
		bool selectedText(BString& text);
		void unselected();

		bool removeSelection();
		bool removeIndex();

	public:	
		BTextEdit*			boss;
		BString				text;
		BTextFormatHolder	format;
		int					lineHeight;
		bool				wordWrap;
		bool				lineWrap;
		bool				readOnly;
		BReal				blinkTick;
		BReal				blinkTime;
		bool				inputShown;

		bool				dirty;
		bool				changed;
		bool				edited;
		bool				gotoInput;
		ILineBlockList		blocklst;
		ILineBlockIterator	inputBlock;
		BPoint				inputLine[2];
		ILineBlockIterator	hoverBlock;
		int					hoverIndex;
		int					pressed;
		ILineBlockIterator	pressBlock;
		int					pressIndex;
		ILineBlockIterator	beginBlock;
		ILineBlockIterator	endBlock;
		ILineBlockIterator	showBegin;
		ILineBlockIterator	showEnd;
	};
}

#endif